<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<%@ include file="isComm.jsp"%>
<%@ include file="..\master\head.jsp"%>
</head>
<body>
<script language="JavaScript" type="text/javascript">
function getXmlHttpRequestObject() {
	if (window.XMLHttpRequest) {
		return new XMLHttpRequest(); //Not IE
	} else if(window.ActiveXObject) {
		return new ActiveXObject("Microsoft.XMLHTTP"); //IE
	} else {
		alert("Your browser doesn't support the XmlHttpRequest object.  Better upgrade to Firefox.");
	}
}			
var receiveReq = getXmlHttpRequestObject();		
function updateP(prjid,stdid) {
	var page = "UpdateAssignment.jsp?prjid="+prjid+"&stdid="+stdid;
	alert(page);
	if (receiveReq.readyState == 4 || receiveReq.readyState == 0) {
		receiveReq.open("GET", page, true);
		receiveReq.onreadystatechange = handleSayHello;
		receiveReq.send(null);
	}
}
function handleSayHello() {
	if (receiveReq.readyState == 4) {
	}
}
</script>
<div id="container">
<div id="wrapper">
<div id="sidebar">
<div id="sb_top"><%@ include file="..\master\sbTop.jsp"%>
</div>

<div class="sb_content"><!--##########--> <!-- Start Menu --> <%@ include
	file="..\master\Profmenu.jsp"%> <!-- Profile -->
<%@ include file="..\master\profile.jsp"%> <!-- links -->
<%@ include file="..\master\links.jsp"%>
<div class="copyright"><%@ include file="..\master\copyright.jsp"%>
</div>
</div>
<!-- /sb_content --></div>
<!-- /sidebar --> <!-- Top -->
<div id="header"><%@ include file="..\master\header.jsp"%>
</div>


<!-- Start main content -->
<div id="content">
<div id="intro">
<div class="intro_t">
<h1><span>..</span>Welcome to<span>..</span></h1>
<h2>student project management system</h2>

</div>
</div>
<!-- /intro -->

<h1>My Projects</h1>
<%@ page import="java.sql.*"%> <%
 	String driver = "sun.jdbc.odbc.JdbcOdbcDriver";
 	try
 	{
 		Class.forName(driver);

 		Connection connection = DriverManager.getConnection(
 				"jdbc:odbc:SPMS", "", "");

 		Statement statement = connection.createStatement();

 		String query = "select student.id , title, Professor.FirstName , "
 				+ "Professor.lastName, Student.FirstName , Student.lastName,GPA from student"
 				+ ",project,studentProject,professor where studentProject.projectid = project.id "
 				+ "and student.id = studentProject.studentid and  professor.id = project.professorid order by student.id,GPA";
 		// Execute query and save results.
 		ResultSet res = statement.executeQuery(query);
 %>
<h3>Recent Projects</h3>
<form action="../DB/deleteProject.jsp" method="post">
<table align="center">
	<tr>
		<td></td>
	</tr>
	<tr>
		<th>Title</th>
		<th>Description</th>
		<th>Professor</th>
	</tr>
	<tr><td>
	<%
			int preprjid = 0,prjid;
			res.next();
			do
			{
				prjid = res.getInt(1);
				if (preprjid != prjid)
				{
					out.println("</select><br><tr><td>");
					out.print(res.getString(5)+" "+res.getString(6)+":  <td>");					
					out.print("<select name = "+prjid+"  onchange='updateP(name,value)' >");
					out.print("<option value= "+prjid+">"+res.getString(2)+":  "+res.getString(3)+" "+res.getString(4)+"</option>");
				}
				else
				{
					out.print("<option value= "+prjid+">"+res.getString(2)+":  "+res.getString(3)+" "+res.getString(4)+"</option>");	
				}
				preprjid = prjid;
			}
			while (res.next());
	%>
	</td>
	<tr>
		<td><input type="submit" value="delete Project" /></td>
		<td></td>
	</tr>
</table>
</form>
<%
	} catch (ClassNotFoundException cnfe)
	{
		out.println("No such class: " + driver);
	} catch (SQLException se)
	{
		out.println("SQLException: " + se);
	}
%>
</div>
<!-- /content --></div>
<!-- /wrapper -->
<div class="clear">&nbsp;</div>
<!-- Important! Fix the problem of height in Firefox --></div>
<!-- /Container -->


</body>
</html>